/*
 * @(#)LocalizedStringTransformer.java
 * Date 2013-09-03
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.transformer.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import oasis.names.tc.ebxml_regrep.xsd.rim._3.InternationalStringType;
import oasis.names.tc.ebxml_regrep.xsd.rim._3.LocalizedStringType;

import us.hornerscorners.lamppost.model.common.LocalizedString;

import us.hornerscorners.lamppost.transformer.AbstractTransformer;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-03
 * @author         Jim Horner
 */
public class LocalizedStringTransformer
        extends AbstractTransformer<InternationalStringType,
            Collection<LocalizedString>> {

    /**
     * Constructs ...
     *
     */
    public LocalizedStringTransformer() {
        super();
    }

    /**
     * Method description
     *
     *
     * @param value
     *
     * @return
     */
    @Override
    public Collection<LocalizedString> transform(InternationalStringType value) {

        List<LocalizedString> result = new ArrayList<>();

        if (value != null) {

            for (LocalizedStringType ltype : value.getLocalizedString()) {

                LocalizedString string = new LocalizedString();

                string.setValue(ltype.getValue());
                string.setCharset(ltype.getCharset());
                string.setLanguage(ltype.getLang());

                result.add(string);
            }
        }

        return result;
    }
}
